public class Demo8 {
    public static int sum1 = 0;
    public static int sum2 = 0;
    public static int[] arr = new int[10000];
    public static void main(String[] args) throws InterruptedException {
        double start = System.currentTimeMillis();
        for (int i = 0; i <10000 ; i++) {
            arr[i]  = i;
        }
        Thread t1 = new Thread(()->{
            for (int i = 1; i <=10000 ; i=i+2) {
                sum1 +=i;
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 2; i <=10000 ; i=i+2) {
                sum2 +=i;
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        double end = System.currentTimeMillis();
        System.out.println(sum1+sum2);
        System.out.println("执行时间="+(end-start)+"ms");
    }
}
